package leetcode.秋招.百度;


import java.util.Arrays;
import java.util.Scanner;

/**
 * @author ：zsy
 * @date ：Created 2021/9/7 18:55
 * @description：
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int factor = in.nextInt();
        int[][] nums = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                nums[i][j] = in.nextInt();
            }
        }
        int[][] ans = new int[n * factor][n * factor];
        int row = 0;
        for (int[] num : nums) {
            int index = 0;
            for (int i = 0; i < num.length; i++) {
                int f = factor;
                while (f > 0) {
                    ans[row][index++] = num[i];
                    f--;
                }
            }
            int f = factor - 1;
            int idx = row;
            while (f > 0) {
                ans[++row] = Arrays.copyOf(ans[idx], n * factor);
                f--;
            }
            row++;
        }
        for (int[] an : ans) {
            for (int i = 0; i < an.length; i++) {
                System.out.print(an[i] + " ");
            }
            System.out.println();
        }
    }
}
